<script setup lang="ts">
import {CommonTable} from "@/components/MyComponent/CommonTable/tableInterface";
import {DictType} from "@/utils/enum-type";
import {
  addWeaponUpApi,
  deleteWeaponUpApi,
  editWeaponUpApi,
  getWeaponUpByIdApi,
  getWeaponUpListApi
} from "@/api/sys/dnf/weapon-up";
import {WeaponUp} from "@/api/sys/dnf/weapon-up/types";

const options: CommonTable<WeaponUp, WeaponUp> = {
  api: {
    add: addWeaponUpApi,
    remove: deleteWeaponUpApi,
    edit: editWeaponUpApi,
    get: getWeaponUpByIdApi,
    getList: getWeaponUpListApi,
  },
  attrs: [
    {
      prop: 'name',
      label: '名称',
      query: false,
    },
    {
      prop: 'weaponType',
      label: '装备类型',
      formType: 'select',
      code: 'dnf_weapon_type'
    },
    {
      prop: 'level',
      label: '增幅等级',
      formType: 'number'
    }, {
      prop: 'cost',
      label: '花费金币数量',
      formType: 'number',
      query: false
    }, {
      prop: 'maodun',
      label: '花费矛盾数量',
      formType: 'number',
      query: false
    }, {
      prop: 'percent',
      label: '成功率',
      formType: 'percent',
      query: false,
    }, {
      prop: 'downLevel',
      label: '失败掉落多少级',
      formType: 'number',
      query: false
    }, {
      prop: 'fame',
      label: '名望加成',
      formType: 'number',
      query: false
    }, {
      prop: 'num',
      label: '数值加成',
      formType: 'number',
      query: false
    }, {
      prop: 'remark',
      label: '描述',
      formType: 'textarea',
      query: false,
      sort: false,
      notDisplayOn: ['list']
    },
    {
      prop: 'status',
      label: '状态',
      formType: 'radio',
      notDisplayOn:['list-phone'],
      query: false,
      code: DictType.Status
    }
  ],
  title: '装备配置',
  queryData: {
    pageSize: 31,
    order:{
      weaponType:'asc',
      level:'asc'
    }
  },
  form: {
    labelWidth: 130,
    initialForm: {
      id: 0,
      name: '',
      weaponType: 1,
      level: 1,
      cost: 10000,
      maodun: 1,
      percent: 1000,
      downLevel: 0,
      fame: 1,
      num: 1,
      status: 1
    },
    rules: {
      name: [{required: true, message: '请输入名称', trigger: 'blur'}],
      weaponType: [{required: true, message: '请选择装备类型', trigger: 'blur'}],
      level: [{required: true, message: '请输入武器增幅等级', trigger: 'blur'},
        {type: 'number', message: '0-31之间', min: 0, max: 31}],
      cost: [{required: true, message: '请输入花费金币数量', trigger: 'blur'},
        {type: 'number', message: '不少于10000', min: 10000}],
      maodun: [{required: true, message: '请输入花费矛盾数量', trigger: 'blur'},
        {type: 'number', message: '最少1个', min: 1}],
      percent: [{required: true, message: '请输入成功率,10000为最高成功率', trigger: 'blur'},
        {type: 'number', message: '1-10000之间', min: 1, max: 10000}],
      downLevel: [{required: true, message: '请输入失败后掉落多少级', trigger: 'blur'},
        {type: 'number', message: '0-30之间', min: 0, max: 30}],
      fame: [{required: true, message: '请输入名望加成数值', trigger: 'blur'},
        {type: 'number', message: '最少为1', min: 1}],
      num: [{required: true, message: '请输入数值加成数量', trigger: 'blur'},
        {type: 'number', message: '最少为1', min: 1}],
    }
  }
}
</script>
<template>
  <x-common-table :options="options"/>
</template>
<style scoped lang="scss">
</style>